package com.nine.common.tool;

import com.fasterxml.jackson.annotation.JsonInclude;




@JsonInclude(JsonInclude.Include.NON_NULL)
public class ResponseResult<T> {
    /**
     * 状态码
     */
    private Integer code;
    /**
     * 提示信息，如果有错误时，前端可以获取该字段进行提示
     */
    private long count;

    private String msg;
    /**
     * 查询到的结果数据，
     */
    private T data;

    public ResponseResult(Integer code, long count,String msg) {
        this.code = code;
        this.count = count;
        this.msg = msg;
    }

    public ResponseResult(Integer code, long count,T data) {
        this.code = code;
        this.data = data;
        this.count=count;
    }

    public ResponseResult(Integer code, String msg, T data) {
        this.code = code;
        this.msg = msg;
        this.data = data;
    }

    public ResponseResult(Integer code,String msg) {
        this.code = code;
        this.msg = msg;
    }
    public ResponseResult(Integer code,T data) {
        this.code = code;
        this.data = data;

    }


    public static <T> ResponseResult<T>  okc(T o,long count){
        return new ResponseResult<T>(0,count,o);
    }

    public static <T> ResponseResult<T>  failc(T o,long count){
        return new ResponseResult<T>(400,count,o);
    }

    public static <T> ResponseResult<T>  ok(T o){
        return new ResponseResult<T>(0,o);
    }

    public static <T> ResponseResult<T>  fail(T o){
        return new ResponseResult<T>(400,o);
    }

    public long getCount() {
        return count;
    }

    public void setCount(long count) {
        this.count = count;
    }

    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public T getData() {
        return data;
    }

    public void setData(T data) {
        this.data = data;
    }


}
